package com.hrm.controller.cam;

import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.validation.BindException;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.AbstractCommandController;

import com.hrm.model.dto.cam.CamViewDTO;
import com.hrm.model.service.CamService;
import com.hrm.model.service.CodeService;

public class CamCheckController extends AbstractCommandController {
	private CamService camService;
	private CodeService codeService;
	
	public void setCamService(CamService camService) {
		this.camService = camService;
	}

	public void setCodeService(CodeService codeService) {
		this.codeService = codeService;
	}

	@Override
	protected ModelAndView handle(HttpServletRequest arg0,
			HttpServletResponse arg1, Object arg2, BindException arg3)
			throws Exception {
				
		CamViewDTO dto = (CamViewDTO)arg2;
		
		
		dto.setId(null);
		List<CamViewDTO> checklist = camService.getAllCam(dto);		
		
		dto = (CamViewDTO)arg2;
		dto = camService.getCam(dto);
					
		ModelAndView mv = new ModelAndView();
						
		mv.addObject("detailCam", dto);
		mv.addObject("checklist",checklist);
		mv.setViewName("detailCam2");
		
		return mv;
	}

}
